$(function() {
	$('#input_sub').on('click', function() {
		let username = $('.input_txt').val();
		let password = $('.input_pass').val();
		if (username.trim() === '' || password.trim() === '') {
			// alert('用户名或密码不能为空');
			$('#tipinfo').text('用户名或者密码不能为空');
			// 显示时传入配置属性
			$('#myModal').modal({ keyboard: true });
			return;
		}
		$.ajax({
			type: 'post',
			// url: 'http://localhost:8080/api/v1/admin/user/login',
			url: window.BigNew.user_login,
			data: {
				username,
				password
			},
			dataType: 'json',
			success: function(res) {
				console.log(res);
				if (res.code === 200) {
					// alert(res.msg);
					$('#tipinfo').text(res.msg);
					$('#myModal').modal('show');
					// location.href = './index.html';
					$('#myModal').on('hidden.bs.modal', function(e) {
						localStorage.setItem('bignews_token', res.token);
						location.href = './index.html';
					});
				} else {
					// alert(res.msg);
					$('#tipinfo').text(res.msg);
					$('#myModal').modal('show');
				}
			}
		});
	});
	// 单击模态框的确定隐藏当前模态框
	$('#btnconfirm').on('click', function() {
		$('#myModal').modal('hide');
	});
});
